package team.szm.scd.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
import team.szm.scd.database.entity.DoctorWorkTime;
import team.szm.scd.database.mapper.DoctorMapper;
import team.szm.scd.database.mapper.DoctorWorkTimeMapper;
import team.szm.scd.database.vo.DoctorVO;
import team.szm.scd.service.interfaces.IDoctorService;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DoctorServiceImpl implements IDoctorService {
    @Resource
    DoctorMapper doctorMapper;

    @Override
    public DoctorVO fromId(String id) {
        QueryWrapper<DoctorVO> wrapper = new QueryWrapper<>();
        wrapper.eq("doctor.did", id);
        List<DoctorVO> l = doctorMapper.doctorsFromQueryWrapper(wrapper);
        if (l == null || l.isEmpty()) {
            return null;
        } else {
            return l.get(0);
        }
    }

    @Resource
    DoctorWorkTimeMapper workTimeMapper;

    @Override
    public List<DoctorWorkTime> workTimesFromId(String id) {
        QueryWrapper<DoctorWorkTime> wrapper = new QueryWrapper<>();
        wrapper.eq("did", id);
        return workTimeMapper.selectList(wrapper);
    }


}
